using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class player_levelstats : MangosBase
	{
		public System.Byte? race;
		public System.Byte? class_;
		public System.Byte? level;
		public System.Byte? str;
		public System.Byte? agi;
		public System.Byte? sta;
		public System.Byte? inte;
		public System.Byte? spi;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `player_levelstats` (`race`, `class`, `level`, `str`, `agi`, `sta`, `inte`, `spi`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}');", race.GetValueOrDefault(), class_.GetValueOrDefault(), level.GetValueOrDefault(), str.GetValueOrDefault(), agi.GetValueOrDefault(), sta.GetValueOrDefault(), inte.GetValueOrDefault(), spi.GetValueOrDefault());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `player_levelstats` SET ");
			if(class_ != null)
			{
				sb.AppendLine("`class`='" + class_.Value.ToString() + "'");
			}
			if(level != null)
			{
				sb.AppendLine("`level`='" + level.Value.ToString() + "'");
			}
			if(str != null)
			{
				sb.AppendLine("`str`='" + str.Value.ToString() + "'");
			}
			if(agi != null)
			{
				sb.AppendLine("`agi`='" + agi.Value.ToString() + "'");
			}
			if(sta != null)
			{
				sb.AppendLine("`sta`='" + sta.Value.ToString() + "'");
			}
			if(inte != null)
			{
				sb.AppendLine("`inte`='" + inte.Value.ToString() + "'");
			}
			if(spi != null)
			{
				sb.AppendLine("`spi`='" + spi.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `race`='" + race.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
